import request from '@/utils/request'

// 查询病虫害管理列表
export function listPestdisease(query) {
  return request({
    url: '/pestdisease/pestdisease/list',
    method: 'get',
    params: query
  })
}


// 🔥 根据作物分类获取病虫害列表
export function getPestDiseaseByCategory(categoryId) {
  return request({
    url: '/pestdisease/pestdisease/listByCategory',
    method: 'get',
    params: categoryId ? { categoryId } : {}
  })
}

// 🔥 获取所有作物分类
export function getPestDiseaseCategories() {
  return request({
    url: '/pestdisease/pestdisease/categories',
    method: 'get'
  })
}

// 🔥 搜索病虫害
export function searchPestDisease(keyword) {
  return request({
    url: '/pestdisease/pestdisease/search',
    method: 'get',
    params: { keyword }
  })
}

// 根据病虫害名称查询详细信息
export function getPestDiseaseByName(name) {
  return request({
    url: '/pestdisease/pestdisease/query',
    method: 'get',
    params: { name }
  })
}



// 查询病虫害管理详细
export function getPestdisease(id) {
  return request({
    url: '/pestdisease/pestdisease/' + id,
    method: 'get'
  })
}

// 新增病虫害管理
export function addPestdisease(data) {
  return request({
    url: '/pestdisease/pestdisease',
    method: 'post',
    data: data
  })
}

// 修改病虫害管理
export function updatePestdisease(data) {
  return request({
    url: '/pestdisease/pestdisease',
    method: 'put',
    data: data
  })
}

// 删除病虫害管理
export function delPestdisease(id) {
  return request({
    url: '/pestdisease/pestdisease/' + id,
    method: 'delete'
  })
}
